//package com.quartet.modules.equipment.controller;
//
//
//import cn.hutool.core.bean.BeanUtil;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.extension.api.ApiController;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.quartet.api.ApiResult;
//import com.quartet.api.PageResult;
//import com.quartet.modules.equipment.dto.TAlarmRuleInfoAddRequestDto;
//import com.quartet.modules.equipment.dto.TAlarmRuleInfoQueryRequestDto;
//import com.quartet.modules.equipment.dto.TAlarmRuleInfoResponseDto;
//import com.quartet.modules.equipment.entity.TAlarmRuleInfo;
//import com.quartet.modules.equipment.service.TAlarmRuleInfoService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.web.bind.annotation.*;
//
//import javax.annotation.Resource;
//import java.util.List;
//import java.util.stream.Collectors;
//
///**
// * 报警规则信息表(TAlarmRuleInfo)表控制层
// *
// * @author makejava
// * @since 2021-05-04 16:22:08
// */
//@RestController
//@RequestMapping("tAlarmRuleInfo")
//@Api(tags = "业务：报警规则信息")
//@Slf4j
//public class TAlarmRuleInfoController  {
//    /**
//     * 服务对象
//     */
//    @Resource
//    private TAlarmRuleInfoService tAlarmRuleInfoService;
//
//    /**
//     * 分页查询所有数据
//     *
//     * @param tAlarmRuleInfoQueryRequestDto 查询实体
//     * @return 所有数据
//     */
//    @ApiOperation("分页查询所有报警规则信息")
//    @PostMapping("/selectAlarmRulePage")
//    public ApiResult<PageResult<TAlarmRuleInfoResponseDto>> selectAlarmRulePage(@RequestBody TAlarmRuleInfoQueryRequestDto tAlarmRuleInfoQueryRequestDto) {
//        log.info("---------selectAlarmRulePage begin, tAlarmRuleInfoQueryRequestDto is {}----------", tAlarmRuleInfoQueryRequestDto);
//        IPage<TAlarmRuleInfo> page = new Page<>(tAlarmRuleInfoQueryRequestDto.getCurrent(), tAlarmRuleInfoQueryRequestDto.getLimit());
//        QueryWrapper<TAlarmRuleInfo> queryWrapper = new QueryWrapper<>();
//        if (!StringUtils.isNotBlank(tAlarmRuleInfoQueryRequestDto.getAlarmRuleName())) {
//            queryWrapper.lambda().like(TAlarmRuleInfo::getAlarmRuleName, tAlarmRuleInfoQueryRequestDto.getAlarmRuleName());
//        }
//        IPage<TAlarmRuleInfo> dbResult = tAlarmRuleInfoService.page(page, queryWrapper);
//        PageResult<TAlarmRuleInfoResponseDto> pageResult = new PageResult();
//        List<TAlarmRuleInfoResponseDto> tAlarmRuleInfoResponseDtoList = dbResult.getRecords().stream().map(tAlarmRuleInfo -> {
//            TAlarmRuleInfoResponseDto tAlarmRuleInfoResponseDto = BeanUtil.copyProperties(tAlarmRuleInfo, TAlarmRuleInfoResponseDto.class);
//            return tAlarmRuleInfoResponseDto;
//        }).collect(Collectors.toList());
//        pageResult.setTotal(dbResult.getTotal());
//        pageResult.setData(tAlarmRuleInfoResponseDtoList);
//        log.info("---------selectAlarmRulePage end, data is {}----------", pageResult);
//        return ApiResult.ok(pageResult);
//    }
//
//    /**
//     * 通过主键查询单条数据
//     *
//     * @param id 主键
//     * @return 单条数据
//     */
//    @ApiOperation("通过主键查询报警规则信息")
//    @GetMapping("/selectAlarmRuleById")
//    public ApiResult<TAlarmRuleInfoResponseDto> selectAlarmRuleById(@RequestParam("id") Integer id) {
//        log.info("---------selectAlarmRuleById begin, id is {}----------", id);
//        TAlarmRuleInfo tAlarmRuleInfo = tAlarmRuleInfoService.getById(id);
//        TAlarmRuleInfoResponseDto tAlarmRuleInfoResponseDto = BeanUtil.copyProperties(tAlarmRuleInfo, TAlarmRuleInfoResponseDto.class);
//        return ApiResult.ok(tAlarmRuleInfoResponseDto);
//    }
//
//    /**
//     * 新增数据
//     *
//     * @param tAlarmRuleInfoAddRequestDto 实体对象
//     * @return 新增结果
//     */
//    @PostMapping("/add")
//    @ApiOperation("新增报警规则信息")
//    public ApiResult addAlarmRule(@RequestBody TAlarmRuleInfoAddRequestDto tAlarmRuleInfoAddRequestDto) {
//        log.info("---------addAlarmRule begin, tAlarmRuleInfoAddRequestDto is {}----------", tAlarmRuleInfoAddRequestDto);
//        TAlarmRuleInfo tAlarmRuleInfo = BeanUtil.copyProperties(tAlarmRuleInfoAddRequestDto, TAlarmRuleInfo.class);
//        return ApiResult.ok(this.tAlarmRuleInfoService.save(tAlarmRuleInfo));
//    }
//
//    /**
//     * 修改数据
//     *
//     * @param tAlarmRuleInfoAddRequestDto 实体对象
//     * @return 修改结果
//     */
//    @PutMapping("/update")
//    @ApiOperation("修改报警规则信息")
//    public ApiResult updateAlarmRule(@RequestBody TAlarmRuleInfoAddRequestDto tAlarmRuleInfoAddRequestDto) {
//        log.info("---------addAlarmRule begin, tAlarmRuleInfoAddRequestDto is {}----------", tAlarmRuleInfoAddRequestDto);
//        TAlarmRuleInfo tAlarmRuleInfo = BeanUtil.copyProperties(tAlarmRuleInfoAddRequestDto, TAlarmRuleInfo.class);
//        return ApiResult.ok(this.tAlarmRuleInfoService.updateById(tAlarmRuleInfo));
//    }
//
//    /**
//     * 删除数据
//     *
//     * @param id 主键
//     * @return 删除结果
//     */
//    @ApiOperation("删除报警规则信息")
//    @DeleteMapping("/delete")
//    public ApiResult deleteAlarmRule(@RequestParam("id") Integer id) {
//        return ApiResult.ok(this.tAlarmRuleInfoService.removeById(id));
//    }
//}
